package com.alibaba.citrus.cr.mn.order.center.facade.function.convert;

import com.alibaba.citrus.cr.common.enums.ordercenter.AutoFulfillmentOrderStatusCirculationEnum;
import com.epoch.app.crforecastsales.enums.AnalyzeReasonsSEO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author baizhuo
 * @version 1.0
 * @date 2023/8/23 11:51
 */
public class AnalyzeReasonToCirculationStatusConvert {

    /**
     * see AnalyzeReasonsSEO.class、 AutoFulfillmentOrderStatusCirculationEnum.class.
     * @param analyzeReason
     * @return
     */

    public static Integer convert(String analyzeReason, boolean activityConflictFlag) {
        if (StringUtils.isEmpty(analyzeReason)) {
            return null;
        }
        if (AnalyzeReasonsSEO.INVENTORY_SHORTAGE.getName().equals(analyzeReason)) {
            return activityConflictFlag ? AutoFulfillmentOrderStatusCirculationEnum.STOCK_NOT_ENOUGH_AND_ACTIVITY_CONFLICT.getCode() : AutoFulfillmentOrderStatusCirculationEnum.STOCK_NOT_ENOUGH.getCode();
        }
        if (AnalyzeReasonsSEO.INSUFFICIENT_ACCOUNTS.getName().equals(analyzeReason)) {
            return activityConflictFlag ? AutoFulfillmentOrderStatusCirculationEnum.CREDIT_NOT_ENOUGH_AND_ACTIVITY_CONFLICT.getCode() : AutoFulfillmentOrderStatusCirculationEnum.CREDIT_NOT_ENOUGH.getCode();
        }
        if (AnalyzeReasonsSEO.TOTALLY_SATISFIED.getName().equals(analyzeReason)) {
            return activityConflictFlag ? AutoFulfillmentOrderStatusCirculationEnum.ACTIVITY_CONFLICT.getCode() : AutoFulfillmentOrderStatusCirculationEnum.ALL_PASS.getCode();
        }
        return activityConflictFlag ? AutoFulfillmentOrderStatusCirculationEnum.OTHER_REASON_AND_ACTIVITY_CONFLICT.getCode() : AutoFulfillmentOrderStatusCirculationEnum.OTHER_REASON.getCode();
    }

}
